package cn.itcast.n4;

import cn.itcast.n2.util.Sleeper;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

import static cn.itcast.n2.util.Sleeper.sleep;

/**
 * className: TestParkUnPark
 * description:
 * date: 2023/2/21-15:35
 * <p>
 * project: concurrent
 * package: cn.itcast.n4
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
@Slf4j(topic = "c.TestParkUnPark")
public class TestParkUnPark {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            log.debug("start...");
            sleep(1);
            log.debug("park...");
            LockSupport.park();
            log.debug("resume...");
        }, "t1");
        t1.start();

        sleep(2);
        log.debug("unPark...");
        LockSupport.unpark(t1);
    }
}
